﻿@using Easy.Web.CMS.Product.Models
@using Easy.ViewPort.jsTree
@{
    Script.Reqiured("jsTree").AtFoot();
}
<div class="panel panel-default">
    <div class="panel-heading">
        产品类别
    </div>
    <div class="panel-body">

        @(
 Html.Tree<ProductCategory>().Source("GetProductCategoryTree", "ProductCategory")
        .AddPlugin(Plugins.ContextMenu)
        .AddContextMenuItem(new ContextmenuItem { Label = "新建", Action = "Create", Icon = "glyphicon glyphicon-plus" })
        .AddContextMenuItem(new ContextmenuItem { Label = "编辑", Action = "Edit", Icon = "glyphicon glyphicon-edit" })
        )

    </div>
    <div class="panel-footer">
        <a href="@Url.Action("Create")" class="btn btn-link btn-xs">
            <i class="glyphicon glyphicon-plus"></i>
            添加类别
        </a>
    </div>
</div>


<script type="text/javascript">
    function Create(node) {
        var parent = node.reference.attr("id");
        window.location.href = '@Url.Action("Create")' + '?ParentID=' + parent;
    }
    function Edit(node) {
        var id = node.reference.attr("id");
        window.location.href = '@Url.Action("Edit")' + '?ID=' + id;
    }


</script>
